package com.xuecheng.auth.config;

import com.aliyun.dysmsapi20170525.Client;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@RefreshScope
public class ALiYunSMSConfig {
    // 阿里云短信配置信息
    @Value("${aliyun.sms.accessKeyId}")
      String accessKeyId;
    @Value("${aliyun.sms.accessKeySecret}")
      String accessKeySecret;
    @Value("${aliyun.sms.endpoint}")
       String endpoint;

    /**
     * <b>description</b> :
     * <p>使用AK&amp;SK初始化账号Client</p>
     * @return Client
     *
     * @throws Exception
     */

    public  Client createClient() throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
                // 您的 AccessKey ID
                .setAccessKeyId(accessKeyId)
                // 您的 AccessKey Secret
                .setAccessKeySecret(accessKeySecret);
        // 访问的域名
        config.endpoint =endpoint ;
        return new com.aliyun.dysmsapi20170525.Client(config);
    }
}
